<?php

namespace App\Http\Resources;

use App\Contract\ContractStatus;
use App\Http\Service\HouseService;
use Illuminate\Http\Resources\Json\ResourceCollection;

class HouseCollection extends ResourceCollection
{
    /**
     * Transform the resource collection into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
    public function toArray($request)
    {
        $houseService = new HouseService();

        return $this->map(function($house) use ($houseService) {
            return $houseService->getHouseForList($house);
        });
    }
}
